//
//  PicPickerCollectionViewCell.swift
//  JIMWeiBo
//
//  Created by 陈恒均 on 2018/2/23.
//  Copyright © 2018年 陈恒均. All rights reserved.
//

import UIKit

class PicPickerCollectionViewCell: UICollectionViewCell {

  
    @IBOutlet weak var imageView: UIImageView!
    @IBOutlet weak var removePhoto: UIButton!
    @IBOutlet weak var addPhoto: UIButton!
    var image : UIImage?{
        didSet{
            if image != nil {
                imageView.image = image
                addPhoto.isUserInteractionEnabled = false
                removePhoto.isHidden = false
            }else{
                imageView.image = nil
                removePhoto.isHidden = true
                addPhoto.isUserInteractionEnabled = true
            }
        }
    }
    
    
    @IBAction func addPhotoClick(_ sender: Any) {
        NotificationCenter.default.post(name:NSNotification.Name(rawValue: PicPickerAddPhotoNote), object: nil)
    }
    @IBAction func removePhotoClick(_ sender: Any) {
        NotificationCenter.default.post(name: NSNotification.Name(rawValue: PicPickerRemovePhotoNote), object: imageView.image)
    }
    
}
